package cn.alone.basic.interceprot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 设置拦截器的详细参数
 * @author lanan
 */
@Configuration  // 申明当前类是Spring的配置类，=== ApplicatonContext.xml
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
               /* 拦截所有请求*/
                .addPathPatterns("/**")
                /*设置放行的请求*/
                .excludePathPatterns(
                        "/login/**",
                        "/user/phone/register",
                        "/shop/settlement",
                        "/fastDfs/**",
                        "/verifycode/**",
                        "/notify",
                        "/searchMasterMsg/**"
                        );
    }
}
